package com.czxy.tanhua.controller;

import com.czxy.tanhua.interceptor.UserHolder;
import com.czxy.tanhua.service.RecommendService;
import com.czxy.tanhua.vo.RecommendPageVo;
import com.czxy.tanhua.vo.ResultList;
import com.czxy.tanhua.vo.UserInfoVo;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Author 爱吃豆的土豆、
 * @Date 2023/4/4 15:57
 */
@RequestMapping("/tanhua")
@RestController
public class RecommendController {
    @Resource
    private RecommendService recommendService;

    @GetMapping("/recommendation")
    public ResponseEntity findAllrecommendation(RecommendPageVo recommendPageVo){
        ResultList allrecommendation = recommendService.findAllrecommendation(recommendPageVo, UserHolder.getUserId());
        return ResponseEntity.ok(allrecommendation);
    }
    @GetMapping("/todayBest")
    public ResponseEntity findtodayBest(){
        UserInfoVo userInfoVo = recommendService.findtodayBest(UserHolder.getUserId());
        return ResponseEntity.ok(userInfoVo);
    }
    @GetMapping("/{id}/personalInfo")
    public ResponseEntity personalInfo(@PathVariable("id") Long id){
        UserInfoVo userInfoVo = recommendService.findUserInfo(id,UserHolder.getUserId());
        return ResponseEntity.ok(userInfoVo);
    }
}
